<!DOCTYPE html>
<html class="x-admin-sm">
<head>
<meta charset="UTF-8">
<title></title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="__ADMIN__/css/font.css">
<link rel="stylesheet" href="__ADMIN__/css/xadmin.css">
<script type="text/javascript" src="__ADMIN__/js/jquery.min.js"></script>
<script type="text/javascript" src="__ADMIN__/js/xadmin.js"></script>
<script type="text/javascript" src="__ADMIN__/js/cookie.js"></script>
{include file="public/layui" /}
<style>
	.layui-btn+.layui-btn{
    margin-left: 0;
}
</style>
</head>

<body>

<div class="x-admin" style="padding:0 10px">
	<div class="layui-table-body layui-table-main" style="width: 1102px;margin:0 auto">
		<table class="layui-table layui-form" id="assessment"></table>
	</div>
</div>
<script type="text/html" id="toolbarDemo">
	<div class="layui-card-body" style="padding-left: 0;float:left;padding-left:0px;padding-top:0;">
		<form class="layui-form layui-col-space5" action="" method="get">
		    <input type="hidden" name="id" value="{$_GET['id']}">
			<div class="layui-inline layui-show-xs-block">
				<input style="width:260px;" type="text" name="keywords" id="search" value="{:input('keywords')}" placeholder="请输入" autocomplete="off" class="layui-input">
			</div>
			<div class="layui-inline layui-show-xs-block">
                <select name="job_id" lay-search>
                <option value="">全部岗位</option>
                {volist name="jobList" id="val"}
                <option value="{$val.id}" {if $_GET['job_id'] == $val['id']} selected {/if} >{$val.name}({$val.count}人)</option>
                {/volist}
                </select>
			</div>
			<div class="layui-inline layui-show-xs-block">
                <select name="department_id">
                <option value="">全部部门</option>
                <option value="1" {if $_GET['department_id'] == 1} selected {/if} >快乐星球</option>
                <option value="2" {if $_GET['department_id'] == 2} selected {/if} >奋斗的大鲸鱼</option>
                <option value="3" {if $_GET['department_id'] == 3} selected {/if} >勤奋的小雪鲸</option>
                <option value="4" {if $_GET['department_id'] == 4} selected {/if} >战神</option>
                </select>
			</div>
			<div class="layui-inline layui-show-xs-block">
				<button class="layui-btn" id="search-btn">
					<i class="layui-icon"></i>
				</button>
			</div>
		</form>
	</div>
</script> 
<script type="text/html" id="department_name">
{{#  if(d.department_id == 1){ }}
<a href="?id={$_GET['id']}&department_id=1"><font color="#ffb800">快乐星球</font></a>
{{#  } }}
{{#  if(d.department_id == 2){ }}
<a href="?id={$_GET['id']}&department_id=2"><font color="#16baaa">奋斗的大鲸鱼</font></a>
{{#  } }}
{{#  if(d.department_id == 3){ }}
<a href="?id={$_GET['id']}&department_id=3"><font color="#1e9fff">勤奋的小雪鲸</font></a>
{{#  } }}
{{#  if(d.department_id == 4){ }}
<a href="?id={$_GET['id']}&department_id=4"><font color="#a233c6">战神</font></a>
{{#  } }}
</script>
<script type="text/html" id="bar">
<div class="layui-clear-space">
{{#  if(d.can_view){ }}
<a class="layui-btn layui-btn-xs" lay-event="view">详情</a>
{{#  } }}
{{#  if(d.can_scoring){ }}
<a class="layui-btn layui-btn-xs " lay-event="scoring">打分</a>
{{#  } }}
{{#  if(d.can_del1){  }}
<a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="del">清除结果</a>
{{#  } }}
</div>
</script> 

<script type="text/html" id="jobnameTpl">
{volist name="jobList" id="val"}
{{#  if(d.job_id == {$val.id}){ }}
{$val.name} ({$val.sum})
{{#  } }}
{/volist}
</script>
<script>
layui.use(['form','layer','jquery','table','util'], function(){
    form = layui.form,
    layer = layui.layer
    ,$ = layui.jquery
    ,table = layui.table
    ,util = layui.util;
    
    table.render({
        elem: '#assessment',
        url:'{:url('assessmentSalesman/scoreResult')}?limit=999&assessment_id={$_GET['id']}&job_id={$_GET['job_id']}&keywords={$_GET['keywords']}&department_id={$_GET['department_id']}', 
        toolbar: '#toolbarDemo',
        defaultToolbar: ['filter', 'exports', 'print', {
          title: '提示',
          layEvent: 'LAYTABLE_TIPS',
          icon: 'layui-icon-tips'
        }],
        height: $(window).height() - 50,
        cellMinWidth: 80,
        //totalRow: true, 
        limis: 9999,
        page: false,
        cols: [function(){
            var arr = [
                {field:'department_id', title:'部门', width:120, align:'center', fixed: 'left' , templet: '#department_name'},
                {field:'admin_name', title:'姓名', width:80, fixed: 'left'},
                {field:'job_name', title:'岗位',  width:150, fixed: 'left'},
                {field:'self_score', title:'自评分', width:90},
                {field:'final_score', title:'上级评分', width:90},
                {field:'scoring_admin_name', title:'评分人',  width:100 },
                {field:'max_score', title:'总分' , width:100 },
                {field:'merit_pay', title:'绩效工资' , width:100  },
                {field:'final_merit_pay', title:'最终绩效' , width:100  },
                {title:'操作', fixed: 'right', width:160, toolbar: '#bar'},
            ];
            
            // 初始化筛选状态
            var local = layui.data('table-filter-assessment111111111'); 
            layui.each(arr, function(index, item){
                if(item.field in local){
                    item.hide = local[item.field];
                }
            });
            return arr;
        }() ],  
        done: function(){
            // 记录筛选状态
            var that = this;
            that.elem.next().on('mousedown', 'input[lay-filter="LAY_TABLE_TOOL_COLS"]+', function(){
                var input = $(this).prev()[0];
                // 此处表名可任意定义
                layui.data('table-filter-assessment11111111111', {
                    key: input.name
                    ,value: input.checked
                })
            });
        }
    });
    
    table.on('edit(assessment)', function(obj){
        var field = obj.field;
        var value = obj.value;
        var data = obj.data;
        layer.msg('编辑成功', {icon: 1});
        
        var update = {};return td.find('select').val();
        update[field] = value;
        obj.update(update);
    });
    
    table.on('tool(assessment)', function(obj){ // 双击 toolDouble
        var data = obj.data; // 获得当前行数据
        // console.log(obj)
        if(obj.event === 'view'){
          layer.open({
            title: data.admin_name+'的考核详情',
            type: 2,
            area: ['1000px','700px'],
            content: '{:url('assessmentSalesman/scoreList')}?id={$_GET['id']}&admin_id='+data.admin_id+'&job_id='+data.job_id
          });
        } else if(obj.event === 'scoring'){
          layer.open({
            title: data.admin_name+'考核打分',
            type: 2,
            area: ['1000px','700px'],
            content: '{:url('assessmentSalesman/scoring')}?id={$_GET['id']}&admin_id='+data.admin_id+'&job_id='+data.job_id
          });
        }  else if(obj.event === 'del'){
            layer.confirm('确定删除此条吗?', function(index){
                $.post('{:url('assessmentSalesman/scoreDel')}',{status:-1,id: obj.data.id},function(){
                    window.history.go(0);
                })
            });
        }
    });
        
});

</script>
</body>

</html>